#coding:utf-8
import os
import hashlib
from readConfig import ReadConfig


def find_new_report(path):
    '获取最新的报告'
    file_list = os.listdir(path)
    if file_list:
        file_list.sort(key=lambda fn:os.path.getmtime(path+'/'+fn),reverse=True)
    return file_list[0]

def convertToMD5(password):
    '字符串采用md5加密'
    m = hashlib.md5()
    m.update(password.encode('utf-8'))
    return m.hexdigest()

def getCofing(section):
    '获取confing.ini配置文件选项信息'
    return ReadConfig.get_section(section)

def getDomain(name):
    '获取配置文件指定域名'
    return getCofing('domain_url')[name]


if __name__ == '__main__':
    # find_new_report('../report')
    print(convertToMD5('e10adc3949ba59abbe56e057f20f883e'))
